package edu.suda.xsap.dto.convert;

import edu.suda.xsap.dto.MemCardDto;
import edu.suda.xsap.entity.MemCard;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

@Mapper(componentModel = "spring")
public interface MemCardDtoToEntityConvert {

    // 单个DTO到Entity的转换
    @Mapping(source = "id", target = "id")
    @Mapping(source = "memberCardName", target = "name")
    @Mapping(source = "price", target = "price")
    @Mapping(source = "note", target = "note")
    @Mapping(source = "type", target = "type")
    @Mapping(source = "availableTimes", target = "totalcount")
    @Mapping(source = "availableDays", target = "totalday")

    MemCard toEntity(MemCardDto dto);

    // DTO列表到Entity列表的转换
    List<MemCard> toEntityList(List<MemCardDto> dtos);
}
